package com.example.kaoshi;

import java.util.Scanner;

/**
 * Created by Quincy on 2018/9/28.
 * 给定数组，可以给其中部分元素加上一个值，给其余元素减去一个值
 * 然后，有没有可能找到一个值使得其所有元素值相等
 */
public class TestCe {
    static boolean flag = false;
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        for (int i = 0; i < k; i++){
            int n = scanner.nextInt();
            int[] arr = new int[n];
            for (int j = 0; j < n; j++){
                arr[j] = scanner.nextInt();
            }
            findArr(arr);
        }
    }

    public static void findArr(int[] arr){
        for (int i = 0; i <= 9; i++){
            if (findPlus(arr, i)){
                System.out.println("YES");
                break;
            }else if (findMinus(arr,i)){
                System.out.println("YES");
                break;
            }

        }
        if (!flag)
            System.out.println("NO");
    }

    public static boolean findPlus(int arr[], int i){
        int a0 = arr[0] + i;
        return common(arr,i,a0);
    }

    public static boolean findMinus(int arr[], int i){
        int a0 = arr[0] - i;
        return common(arr, i, a0);
    }

    public static boolean common(int[] arr,int i, int a0){
        for (int j = 1; j < arr.length; j++){
            if ((arr[j] += i) == a0 || (arr[j] -= i) == a0)
                flag = true;
            else{
                flag = false;
                break;
            }
        }
        return flag;
    }

}
